<template>
  <section class="content">
    <div class="box box-info">
      <div class="box-header with-border">
        <h3 class="box-title">筛选查询</h3>
      </div>
      <div class="form-horizontal">
        <div class="box-body">
          <div class="form-group">
            <div class="col-sm-3 flex">
              <label class="min-width control-label">平台渠道：</label>
              <div class="inline-block">
                <select class="form-control" v-model="conditions.channel" @change="platformChannels">
                  <option value="0">请选择平台渠道</option>
                  <option :value="platformChannel.id" v-for="(platformChannel , index) in platformChannelsBtns">{{platformChannel.platformName}}</option>
                </select>
              </div>
            </div>
            <div class="col-sm-3 flex">
              <label class="min-width control-label">店铺账号：</label>
              <div class="inline-block">
                <select class="form-control" v-model="conditions.account">
                  <option value="">请选择店铺账号</option>
                  <option :value="shopListBtnItem.id" v-for="(shopListBtnItem , index) in shopListBtn">{{shopListBtnItem.name}}</option>
                </select>
              </div>
            </div>

          </div>
          <div class="form-group">
            <div class="col-sm-3 flex">
              <label class="min-width control-label">订单编号：</label>
              <div class="inline-block">
                <input type="text" class="form-control" v-model="conditions.platformOrderId" placeholder="请输入订单编号">
              </div>
            </div>
            <div class="col-sm-6 flex">
              <label class="min-width control-label">订单日期：</label>
              <div class="inline-block">
                <div class="inline-block">
                  <el-date-picker class="pull-left linehe" style="width:calc(42% - 15px);height: 34px;line-height: 34px;padding-left: 0;"
                                  v-model="conditions.begin"
                                  type="datetime"
                                  placeholder="开始时间" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                  <span class="pull-left " style="line-height: 34px;padding: 0 1%">至</span>
                  <el-date-picker class="pull-left linehe" style="width:calc(42% - 15px)" v-model="conditions.end"
                                  type="datetime"
                                  placeholder="结束时间" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                </div>
              </div>
            </div>
            <div class="pull-left" v-if="$_has('sys:order:u8')">
              <button class="btn btn-success" @click="getOrderList">查 询</button>
              <button class="btn btn-primary m-lr-10" @click="u8OrderDownload">导 出</button>
              <button class="btn btn-danger" @click="clearCondtionParam">重 置</button>
            </div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-xs-12">
          <div class="box box-info">
            <div class="box-header with-border">
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example3" class="table table-bordered">
                <thead>
                <tr>
                  <th style="line-height: 40px;">商品信息</th>
                  <th style="line-height: 40px;">单价</th>
                  <th style="line-height: 40px;">数量</th>
                  <th style="line-height: 40px;">小计</th>
                  <th style="line-height: 40px;">订单金额</th>
                  <th style="line-height: 40px;">平台</th>
                  <th style="line-height: 40px;">状态</th>
                  <th style="line-height: 40px;" width="15%">订单时间</th>
                  <th style="line-height: 40px;">配送信息</th>
                </tr>
                </thead>
                <tbody>
                <tr v-if="orderList.length == 0">
                  <td colspan="9">没有数据</td>
                </tr>
                <template v-else v-for="orderItem in orderList">
                  <tr class="bg-info">
                    <td colspan="9" class="text-left">
                      <label>
                        <!--<input type="checkbox" class="flat-red">-->
                        <span class="m-lr-10" style="line-height: 34px;">
                        订单编号：{{orderItem.platformOrderId}}
                      </span>
                      </label>
                    </td>
                    <td colspan="2" class="text-right">
                    </td>
                  </tr>
                  <template v-for="(item, index) in orderItem.items">
                    <tr>
                      <td colspan="2" class="text-left" style="padding-left: 20px;width: 30%">
                        <img v-if="item.image" :src="item.image" alt="">
                        <img v-else src="@/assets/noPic.png" alt="">
                        <label class="m-l-15" style="width: 80%">
                          <p>
                            <label>商品编码：</label>
                            <span class="overHidden">{{item.itemId}}</span>
                          </p>
                          <p>
                            <label>商品名称：</label>
                            <span class="overHidden">{{item.title}}</span>
                          </p>
                          <p>
                            <label>品牌名称：</label>
                            <span class="overHidden">{{item.conditionName}}</span>
                          </p>
                        </label>
                      </td>
                      <td>{{ item.price == null ? 0:item.price | moneyFormat}}</td>
                      <td>{{item.quantity == null ? 0:item.quantity}}</td>
                      <td>{{(item.price == null || item.quantity == null) ? 0:item.price*item.quantity | moneyFormat}}
                      </td>
                      <td v-if="orderItem.items.length>=1 && index==0" :rowspan="orderItem.items.length">
                        <p>
                          {{orderItem.total == null ? 0:orderItem.total | moneyFormat}}
                        </p>
                        (含运费：{{orderItem.shippingPrice == null ? 0:orderItem.shippingPrice | moneyFormat}})
                      </td>
                      <td class="text-center" v-if="orderItem.items.length>=1 && index==0" :rowspan="orderItem.items.length">
                        {{getPlatFormName(orderItem.channel)}}
                      </td>
                      <td class="text-center" v-if="orderItem.items.length>=1 && index==0" :rowspan="orderItem.items.length">
                        {{getOrderStatus(orderItem.status)}}
                      </td>
                      <td class="text-center" v-if="orderItem.items.length>=1 && index==0" :rowspan="orderItem.items.length">
                        {{orderItem.orderCreated}}
                    </td>
                      <td class="text-left" v-if="orderItem.items.length>=1 && index==0"
                          :rowspan="orderItem.items.length">
                        <p>收件人：{{orderItem.receiver}}[{{orderItem.receiverCountry}}]</p>

                        <p>配送仓库：{{orderItem.wareHouse}}</p>

                        <!--<p>物流渠道：<a href="" data-toggle="modal" data-target="#modal-Delivery" @click="getLogisticsList">请选择物流渠道</a></p>-->
                        <p>物流渠道：{{orderItem.logistics}}</p>
                      </td>
                    </tr>
                  </template>
                </template>
                </tbody>
              </table>
              <div class="clearfix" v-if="orderList.length != 0">
                <div class="m-t-15 pull-right">
                  <pagination :total="pages.total" :current-page='pages.current' :display="pages.display"
                              @pagechange="pagechange"></pagination>
                </div>
              </div>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
    </div>
  </section>
</template>

<script>
  import orderList from '@/js/order/exportOrder'

  export default orderList
</script>

<style>
  .linehe > input {
    line-height: 34px !important;
    height: 36px !important;
  }

  .el-input__inner {
    line-height: 34px !important;
    height: 36px !important;
  }

  .el-input__icon {
    line-height: 34px !important;
  }
</style>
